home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / pack / gzip107p.lha / gzip.diff
Text File  |  1993-04-13  |  14KB  |  574 lines

  1. diff --recursive --minimal --unified --new-file Old/SCOptions SCOptions
  2. --- Old/SCOptions
  3. +++ SCOptions    Tue Apr 13 15:29:16 1993
  4. @@ -0,0 +1,32 @@
  5. +Ansi
  6. +Batch
  7. +Data=Far
  8. +Error=All
  9. +ErrorRexx
  10. +IncludeDir=A20:
  11. +MemSize=Huge
  12. +Modified
  13. +NoIcons
  14. +NoMultipleIncludes
  15. +NoStackCheck
  16. +OnError=Continue
  17. +Optimize
  18. +OptimizerComplexity=6
  19. +OptimizerDepth=6
  20. +OptimizerInlineLocal
  21. +OptimizerRecurDepth=6
  22. +OptimizerTime
  23. +OptGo
  24. +OptPeep
  25. +Parameters=Registers
  26. +SmallCode
  27. +Startup=c
  28. +Strict
  29. +StringMerge
  30. +StripDebug
  31. +Verbose
  32. +Define USE_BUILTIN_MATH
  33. +Define AMIGA
  34. +Define STDC_HEADERS
  35. +Ignore 149
  36. +Ignore 178
  37. diff --recursive --minimal --unified --new-file Old/SMakefile SMakefile
  38. --- Old/SMakefile
  39. +++ SMakefile    Tue Apr 13 15:29:16 1993
  40. @@ -0,0 +1,59 @@
  41. +# Makefile for gzip (GNU zip)    -*- Indented-Text -*-
  42. +# This Makefile is for SAS/C 6.2 on the Amiga
  43. +# Made by Carsten Steger (carsten.steger@informatik.tu-muenchen.de)
  44. +# Modified by Jörg Plate <Joerg.Plate@Informatk.Uni-Oldenburg.de>
  45. +
  46. +# Some notes on gzip for the Amiga:
  47. +# Due to a broken implementation of readdir() in the SAS/C 6.2 library
  48. +# you should not use gzip -r on a directory in the RAM-Disk. To zip all
  49. +# files in a directory 'dir' in the RAM-Disk use something like
  50. +# gzip ram:dir/#? ram:dir/#?/#? ...
  51. +# where the number of '#?'s reflects the depth of the directory 'dir'.
  52. +#
  53. +# Alas, the program has it's full functionality only if you have
  54. +# Kickstart 2.0 or higher installed. This affects the expansion of
  55. +# wildcards and the preservation of file access times. You should use
  56. +# a shell that does wildcard expansion under Kickstart 1.3.
  57. +
  58. +CC = sc
  59. +
  60. +#OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \
  61. +#       crypt.o lzw.o unlzw.o unpack.o getopt.o alloca.o tailor.o match.o
  62. +
  63. +OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \
  64. +lzw.o unlzw.o unpack.o getopt.o alloca.o tailor.o match.o
  65. +
  66. +.c.o:
  67. +    $(CC) $<
  68. +
  69. +.a.o:
  70. +    $(CC) $<
  71. +
  72. +all: gzip
  73. +
  74. +gzip: $(OBJS)
  75. +    $(CC) link $(OBJS) TO $@
  76. +
  77. +gzip.o: gzip.c gzip.h tailor.h revision.h lzw.h getopt.h
  78. +zip.o: zip.c gzip.h tailor.h crypt.h
  79. +deflate.o: deflate.c gzip.h tailor.h
  80. +bits.o: bits.c gzip.h tailor.h crypt.h
  81. +unzip.o: unzip.c gzip.h tailor.h crypt.h
  82. +inflate.o: inflate.c gzip.h tailor.h
  83. +util.o: util.c gzip.h tailor.h crypt.h
  84. +lzw.o: lzw.c lzw.h gzip.h tailor.h
  85. +unlzw.o: unlzw.c gzip.h tailor.h revision.h lzw.h
  86. +unpack.o: unpack.c gzip.h tailor.h
  87. +crypt.o: crypt.c gzip.h tailor.h
  88. +getopt.o: getopt.c getopt.h
  89. +tailor.o: tailor.c
  90. +
  91. +alloca.o: alloca.c
  92. +    $(CC) DEF=STACK_DIRECTION=-1 $<
  93. +
  94. +match.o: match.a
  95. +
  96. +# Compile trees.c without optimization (produces incorrect code)
  97. +
  98. +trees.o: trees.c gzip.h tailor.h
  99. +    $(CC) noopt $<
  100. diff --recursive --minimal --unified --new-file Old/alloca.c alloca.c
  101. --- Old/alloca.c    Tue Apr 13 15:31:50 1993
  102. +++ alloca.c    Tue Apr 13 15:28:46 1993
  103. @@ -56,8 +56,14 @@
  104.  
  105.  #define    NULL    0            /* null pointer constant */
  106.  
  107. +#ifdef __SASC_60
  108. +pointer alloca (unsigned);
  109. +extern void    free(pointer);
  110. +extern pointer    xmalloc(unsigned);
  111. +#else
  112.  extern void    free();
  113.  extern pointer    xmalloc();
  114. +#endif
  115.  
  116.  /*
  117.      Define STACK_DIRECTION if you know the direction of stack
  118. --- Old/getopt.c    Tue Apr 13 15:31:53 1993
  119. +++ getopt.c    Tue Apr 13 16:31:19 1993
  120. @@ -19,6 +19,18 @@
  121.     along with this program; if not, write to the Free Software
  122.     Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  123.  
  124. +#ifdef __SASC_60
  125. +static char * my_index(char const * string, int chr);
  126. +static void my_bcopy(char * from, char * to, int size);
  127. +static void exchange(char ** argv);
  128. +int _getopt_internal(int , char * const * , char const * , struct option const * , int * , int );
  129. +int getopt(int argc, char * const * argv, char const * optstring);
  130. +int getopt_long(int , char * const * , char const * , struct option const * , int * );
  131. +int getopt_long_only(int , char * const * , char const * , struct option const * , int * );
  132. +extern void *alloca (int);
  133. +extern char *getenv (char *);
  134. +#endif
  135. +
  136.  /* AIX requires this to be the first thing in the file.  */
  137.  #ifdef __GNUC__
  138.  #define alloca __builtin_alloca
  139. @@ -29,8 +41,10 @@
  140.  #ifdef _AIX
  141.   #pragma alloca
  142.  #else
  143. +#ifndef __SASC_60
  144.  char *alloca ();
  145.  #endif
  146. +#endif
  147.  #endif /* alloca.h */
  148.  #endif /* not __GNUC__ */
  149.  
  150. @@ -152,6 +166,12 @@
  151.  #define    my_bcopy(src, dst, n)    memcpy ((dst), (src), (n))
  152.  #else
  153.  
  154. +#ifdef __SASC_60
  155. +#include <string.h>
  156. +#define    my_index strchr
  157. +#define    my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
  158. +#else
  159. +
  160.  /* Avoid depending on library functions or files
  161.     whose names are inconsistent.  */
  162.  
  163. @@ -180,6 +200,7 @@
  164.    for (i = 0; i < size; i++)
  165.      to[i] = from[i];
  166.  }
  167. +#endif
  168.  #endif                /* GNU C library.  */
  169.  
  170.  /* Handle permutation of arguments.  */
  171. diff --recursive --minimal --unified --new-file Old/match.a match.a
  172. --- Old/match.a
  173. +++ match.a    Tue Apr 13 15:29:16 1993
  174. @@ -0,0 +1,175 @@
  175. +; match.a -- optional optimized asm version of longest match in deflate.c
  176. +; Copyright (C) 1992-1993 Jean-loup Gailly
  177. +; This is free software; you can redistribute it and/or modify it under the
  178. +; terms of the GNU General Public License, see the file COPYING.
  179. +; $Id: match.a,v 1.1 1993/03/11 16:05:57 jloup Exp $
  180. +;
  181. +; Adapted for the Amiga by Carsten Steger <stegerc@informatik.tu-muenchen.de>
  182. +; using the code in match.S.
  183. +; The major change in this code consists of removing all unaligned
  184. +; word accesses, because they cause 68000-based Amigas to crash.
  185. +; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc.
  186. +; The program will then only run on 68020-based Amigas, though.
  187. +;
  188. +; This code will run with registerized parameters too, unless SAS
  189. +; changes parameter passing conventions between new releases of SAS/C.
  190. +
  191. +
  192. +Cur_Match    reg    d0    ; Must be in d0!
  193. +Best_Len    reg    d1
  194. +Loop_Counter    reg    d2
  195. +Scan_Start    reg    d3
  196. +Scan_End    reg    d4
  197. +Limit        reg    d5
  198. +Chain_Length    reg    d6
  199. +Scan_Test    reg    d7
  200. +Scan        reg    a0
  201. +Match        reg    a1
  202. +Prev_Address    reg    a2
  203. +Scan_Ini    reg    a3
  204. +Match_Ini    reg    a4
  205. +
  206. +MAX_MATCH    equ    258
  207. +MIN_MATCH    equ    3
  208. +WSIZE        equ    32768
  209. +MAX_DIST    equ    WSIZE-MAX_MATCH-MIN_MATCH-1
  210. +
  211. +
  212. +    xref    _max_chain_length
  213. +    xref    _prev_length
  214. +    xref    _prev
  215. +    xref    _window
  216. +    xref    _strstart
  217. +    xref    _good_match
  218. +    xref    _match_start
  219. +    xref    _nice_match
  220. +
  221. +
  222. +    section match,code
  223. +
  224. +    xdef    _match_init
  225. +    xdef    @match_init
  226. +    xdef    _longest_match
  227. +    xdef    @longest_match
  228. +
  229. +
  230. +_match_init:
  231. +@match_init:
  232. +    rts
  233. +
  234. +
  235. +_longest_match:
  236. +    move.l    4(sp),Cur_Match
  237. +@longest_match:
  238. +    ifd    UNALIGNED_OK
  239. +    movem.l    d2-d6/a2-a4,-(sp)
  240. +    else
  241. +    movem.l    d2-d7/a2-a4,-(sp)
  242. +    endc
  243. +    move.l    _max_chain_length,Chain_Length
  244. +    move.l    _prev_length,Best_Len
  245. +    lea    _prev,Prev_Address
  246. +    lea    _window+MIN_MATCH,Match_Ini
  247. +    move.l    _strstart,Limit
  248. +    move.l    Match_Ini,Scan_Ini
  249. +    add.l    Limit,Scan_Ini
  250. +    subi.w    #MAX_DIST,Limit
  251. +    bhi.b    limit_ok
  252. +    moveq    #0,Limit
  253. +limit_ok:
  254. +    cmp.l    _good_match,Best_Len
  255. +    bcs.b    length_ok
  256. +    lsr.l    #2,Chain_Length
  257. +length_ok:
  258. +    subq.l    #1,Chain_Length
  259. +
  260. +    ifd    UNALIGNED_OK
  261. +
  262. +    move.w    -MIN_MATCH(Scan_Ini),Scan_Start
  263. +    move.w    -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
  264. +
  265. +    else
  266. +
  267. +    move.b    -MIN_MATCH(Scan_Ini),Scan_Start
  268. +    lsl.w    #8,Scan_Start
  269. +    move.b    -MIN_MATCH+1(Scan_Ini),Scan_Start
  270. +    move.b    -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
  271. +    lsl.w    #8,Scan_End
  272. +    move.b    -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
  273. +
  274. +    endc
  275. +
  276. +    bra.b    do_scan
  277. +
  278. +long_loop:
  279. +
  280. +    ifd    UNALIGNED_OK
  281. +
  282. +    move.w    -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
  283. +
  284. +    else
  285. +
  286. +    move.b    -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
  287. +    lsl.w    #8,Scan_End
  288. +    move.b    -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
  289. +
  290. +    endc
  291. +
  292. +short_loop:
  293. +    lsl.w    #1,Cur_Match
  294. +    move.w    0(Prev_Address,Cur_Match),Cur_Match
  295. +    cmp.w    Limit,Cur_Match
  296. +    dbls    Chain_Length,do_scan
  297. +    bra.b    return
  298. +
  299. +do_scan:
  300. +    move.l    Match_Ini,Match
  301. +    add.l    Cur_Match,Match
  302. +
  303. +    ifd    UNALIGNED_OK
  304. +
  305. +    cmp.w    -MIN_MATCH-1(Match,Best_Len),Scan_End
  306. +    bne.b    short_loop
  307. +    cmp.w    -MIN_MATCH(Match),Scan_Start
  308. +    bne.b    short_loop
  309. +
  310. +    else
  311. +
  312. +    move.b    -MIN_MATCH-1(Match,Best_Len),Scan_Test
  313. +    lsl.w    #8,Scan_Test
  314. +    move.b    -MIN_MATCH(Match,Best_Len),Scan_Test
  315. +    cmp.w    Scan_Test,Scan_End
  316. +    bne.b    short_loop
  317. +    move.b    -MIN_MATCH(Match),Scan_Test
  318. +    lsl.w    #8,Scan_Test
  319. +    move.b    -MIN_MATCH+1(Match),Scan_Test
  320. +    cmp.w    Scan_Test,Scan_Start
  321. +    bne.b    short_loop
  322. +
  323. +    endc
  324. +
  325. +    move.w    #(MAX_MATCH-MIN_MATCH),Loop_Counter
  326. +    move.l    Scan_Ini,Scan
  327. +scan_loop:
  328. +    cmpm.b    (Match)+,(Scan)+
  329. +    dbne    Loop_Counter,scan_loop
  330. +
  331. +    sub.l    Scan_Ini,Scan
  332. +    addq.l    #(MIN_MATCH-1),Scan
  333. +    cmp.l    Best_Len,Scan
  334. +    bls.b    short_loop
  335. +    move.l    Scan,Best_Len
  336. +    move.l    Cur_Match,_match_start
  337. +    cmp.l    _nice_match,Best_Len
  338. +    bcs.b    long_loop
  339. +return:
  340. +    move.l    Best_Len,d0
  341. +    ifd    UNALIGNED_OK
  342. +    movem.l    (sp)+,d2-d6/a2-a4
  343. +    else
  344. +    movem.l    (sp)+,d2-d7/a2-a4
  345. +    endc
  346. +    rts
  347. +
  348. +    end
  349. diff --recursive --minimal --unified --new-file Old/tailor.c tailor.c
  350. --- Old/tailor.c
  351. +++ tailor.c    Tue Apr 13 15:28:50 1993
  352. @@ -0,0 +1,183 @@
  353. +/* tailor.c -- target dependent functions
  354. + * Copyright (C) 1993 Carsten Steger (carsten.steger@informatik.tu-muenchen.de)
  355. + * This is free software; you can redistribute it and/or modify it under the
  356. + * terms of the GNU General Public License, see the file COPYING.
  357. + */
  358. +
  359. +/*
  360. + * This file contains Amiga specific functions for gzip.
  361. + */
  362. +
  363. +#include <stdio.h>
  364. +#include <stdlib.h>
  365. +#include <string.h>
  366. +#include <error.h>
  367. +#include <time.h>
  368. +#include <utime.h>
  369. +#include <exec/types.h>
  370. +#include <dos/dos.h>
  371. +#include <dos/dosextens.h>
  372. +#include <dos/dosasl.h>
  373. +#include <proto/dos.h>
  374. +
  375. +#define MAXPATH 1024
  376. +#define MAXARGS 512
  377. +
  378. +extern struct DosLibrary *DOSBase;
  379. +
  380. +extern void *xmalloc(unsigned int size);
  381. +
  382. +static char *expand_next_file (char *pattern);
  383. +static int in_prev_args (char *arg, char **argv, int argc);
  384. +extern void _expand_args (int *oargc, char ***oargv);
  385. +
  386. +
  387. +static char *expand_next_file (pattern)
  388. +     char *pattern;
  389. +{
  390. +  long err;
  391. +  char *pathname;
  392. +  static struct AnchorPath *an = NULL;
  393. +
  394. +  pathname = NULL;
  395. +  if (pattern == NULL)
  396. +    err = -1;
  397. +  else
  398. +    do
  399. +      {
  400. +        if (an == NULL)
  401. +          {
  402. +            an = xmalloc (sizeof (struct AnchorPath) + MAXPATH);
  403. +            memset (an, 0, sizeof (struct AnchorPath) + MAXPATH);
  404. +            an->ap_BreakBits = SIGBREAKF_CTRL_C;
  405. +            an->ap_Strlen = MAXPATH;
  406. +            an->ap_Flags = APF_DOWILD;
  407. +            err = MatchFirst (pattern, an);
  408. +          }
  409. +        else
  410. +          err = MatchNext (an);
  411. +
  412. +        pathname = an->ap_Buf;
  413. +      } while (err == 0 && pathname == NULL);
  414. +
  415. +  if (err)
  416. +    {
  417. +      MatchEnd (an);
  418. +      free (an);
  419. +      an = NULL;
  420. +      return NULL;
  421. +    }
  422. +  else
  423. +    return pathname;
  424. +}
  425. +
  426. +
  427. +static int in_prev_args (arg, argv, argc)
  428. +     char *arg, **argv;
  429. +     int argc;
  430. +{
  431. +  int i, is_in_args;
  432. +
  433. +  is_in_args = 0;
  434. +  for (i = 1; i < argc - 1; i++)
  435. +    if (stricmp (arg, argv[i]) == 0)
  436. +      is_in_args = 1;
  437. +  return is_in_args;
  438. +}
  439. +
  440. +
  441. +void _expand_args (oargc, oargv)
  442. +     int *oargc;
  443. +     char ***oargv;
  444. +{
  445. +  int i;
  446. +  char *str, **argv;
  447. +  static char buf[MAXPATH];
  448. +  int argc, no_match_at_all, num_matches, contains_wildcards;
  449. +
  450. +  /* With Kickstart 1.3 wildcards can't be expanded. */
  451. +  if (DOSBase->dl_lib.lib_Version < 37) return;
  452. +
  453. +  no_match_at_all = 1;
  454. +  contains_wildcards = 0;
  455. +  argc = 0;
  456. +  argv = xmalloc (MAXARGS * sizeof (char *));
  457. +
  458. +  argv[argc++] = (*oargv)[0];
  459. +  for (i = 1; i < *oargc; i++)
  460. +    {
  461. +      if (ParsePattern ((*oargv)[i], buf, MAXPATH))
  462. +        {
  463. +          contains_wildcards = 1;
  464. +          num_matches = 0;
  465. +          while (str = expand_next_file ((*oargv)[i]))
  466. +            if (argc >= MAXARGS)
  467. +              {
  468. +                expand_next_file (NULL);
  469. +                fprintf (stderr,"Too many files.\n");
  470. +                exit (20);
  471. +              }
  472. +            else
  473. +              {
  474. +                /* Avoid duplicate entries */
  475. +                if (!in_prev_args (str, argv, argc))
  476. +                  {
  477. +                    argv[argc++] = strdup (str);
  478. +                    num_matches++;
  479. +                  }
  480. +              }
  481. +          if (num_matches != 0)
  482. +            no_match_at_all = 0;
  483. +        }
  484. +      else
  485. +        if (argc >= MAXARGS)
  486. +          {
  487. +            fprintf (stderr,"Too many files.\n");
  488. +            exit (20);
  489. +          }
  490. +        else
  491. +          {
  492. +            if (!in_prev_args ((*oargv)[i], argv, argc))
  493. +              argv[argc++] = (*oargv)[i];
  494. +          }
  495. +    }
  496. +  *oargc = argc;
  497. +  *oargv = argv;
  498. +  if (no_match_at_all && contains_wildcards) {
  499. +    fprintf (stderr,"No match.\n");
  500. +    exit (20);
  501. +  }
  502. +}
  503. +
  504. +
  505. +int utime (path, times)
  506. +     char *path;
  507. +     struct utimbuf *times;
  508. +{
  509. +  struct DateStamp date;
  510. +  LONG error;
  511. +  time_t modtime;
  512. +
  513. +  /* With Kickstart 1.3 setting the filedate could be done, I guess.
  514. +   * Maybe someone else will implement and test the code for this
  515. +   * case (I don't have Kickstart 1.3). */
  516. +  if (DOSBase->dl_lib.lib_Version < 37) return 0;
  517. +
  518. +  /* Amiga dates are counted from 1. Jan 1978 as opposed to 1. Jan 1970
  519. +   * on Unix. Therefore we have to subtract 2922 days (8*365+2). We also
  520. +   * have to subtract the value of __timezone since SAS/C uses "CST+06"
  521. +   * as the default value. */
  522. +  modtime = times->modtime - __timezone;
  523. +  date.ds_Days = (modtime / 86400) - 2922;
  524. +  modtime %= 86400;
  525. +  date.ds_Minute = modtime / 60;
  526. +  modtime %= 60;
  527. +  date.ds_Tick = modtime * TICKS_PER_SECOND;
  528. +  error = SetFileDate (path, &date);
  529. +  if (error == DOSFALSE)
  530. +    {
  531. +      errno = EOSERR;
  532. +      return -1;
  533. +    }
  534. +  return 0;
  535. +}
  536. diff --recursive --minimal --unified --new-file Old/unlzw.c unlzw.c
  537. --- Old/unlzw.c    Tue Apr 13 15:32:04 1993
  538. +++ unlzw.c    Tue Apr 13 15:28:50 1993
  539. @@ -146,12 +146,12 @@
  540.  };
  541.  
  542.  #if BYTEORDER == 4321 && NOALLIGN == 1
  543. -#  define input(b,o,c,n,m){ \
  544. +#  define input(b,o,c,n,m) { \
  545.       (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \
  546.       (o) += (n); \
  547.     }
  548.  #else
  549. -#  define input(b,o,c,n,m){ \
  550. +#  define input(b,o,c,n,m) { \
  551.       REG1 char_type *p = &(b)[(o)>>3]; \
  552.       (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \
  553.       ((long)(p[2])<<16))>>((o)&0x7))&(m); \
  554. diff --recursive --minimal --unified --new-file Old/utime.h utime.h
  555. --- Old/utime.h
  556. +++ utime.h    Tue Apr 13 15:29:08 1993
  557. @@ -0,0 +1,15 @@
  558. +#ifndef _UTIME_H
  559. +#define _UTIME_H 1
  560. +
  561. +#ifndef _TIME_H
  562. +#include <time.h>
  563. +#endif
  564. +
  565. +struct utimbuf {
  566. +  time_t actime;
  567. +  time_t modtime;
  568. +};
  569. +
  570. +extern int utime (char *path, struct utimbuf *times);
  571. +
  572. +#endif
  573.